﻿using System;
using System.Text;

namespace Tab2Sql
{
    /// <summary>
    /// For non-standard parse jobs like importing in specific (external) log files.
    /// </summary>
    public static class SpecialParse
    {
        /// <summary>
        /// For Microsoft logs. Can't remember which format / what this is about though.
        /// TODO : Delete this.
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static string AdjustMSLogs(string input)
        {
            var MainBody = new StringBuilder();
            string fieldList = "";
            input = input.Replace(' ', '\t');
            string[] lines = input.Split('\n');
            foreach (string line in lines)
            {
                if (line.StartsWith("#"))
                {
                    if (line.StartsWith("#fields"))
                    {
                        fieldList = line.Replace("#fields:\t", String.Empty);
                    }
                }
                else
                {
                    MainBody.AppendLine(line);
                }
            }
            string endResult = fieldList + Environment.NewLine + MainBody;
            return endResult;
        }

        
    }
}